# Find installed CVD

# CVD requires TooN
find_package(TooN)

# find include path
find_path(CVD_INCLUDE_DIR
  NAMES cvd/image.h
  DOC "CVD include path"
)

# find static library
find_library(CVD_LIBRARY
  NAMES cvd
  DOC "CVD library path"
)

set(CVD_INCLUDE_DIRS ${CVD_INCLUDE_DIR} ${TooN_INCLUDE_DIRS})
set(CVD_LIBRARIES ${CVD_LIBRARY} ${TooN_LIBRARIES})

if (TooN_FOUND AND CVD_INCLUDE_DIR AND CVD_LIBRARY)
   set(CVD_FOUND TRUE)
   if (NOT CVD_FIND_QUIETLY)
      message (STATUS "Found CVD: ${CVD_LIBRARY}")
   endif()
else()
   set(CVD_FOUND FALSE)
   if (CVD_FIND_REQUIRED)
      if (NOT TooN_FOUND)
         message(FATAL_ERROR "Could not find TooN (required by CVD)")
      else()
         message(FATAL_ERROR "Could not find CVD")
      endif()
   endif()
endif()
